package Principal;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

public class FormatoTabla extends DefaultTableCellRenderer{

    private int columna_patron ;
DefaultTableModel dtm;
    public FormatoTabla(int Colpatron, DefaultTableModel dt)
    {
        this.columna_patron = Colpatron;
        dtm=dt;
    }

    @Override
    public Component getTableCellRendererComponent ( JTable table, Object value, boolean selected, boolean focused, int row, int column )
    {       
        row=table.convertRowIndexToModel(row);
        setBackground(Color.white);//color de fondo
        table.setForeground(Color.black);//color de texto
        //Si la celda corresponde a una fila con estado FALSE, se cambia el color de fondo a rojo
        
        if( (int)dtm.getValueAt(row,columna_patron)<=3 )
        {
            setBackground(Color.yellow);
           // table.setForeground(Color.red);
        }
        if( (int)dtm.getValueAt(row,columna_patron)<=0 )
        {
            setBackground(Color.red);
            table.setForeground(Color.white);
        }
        

        super.getTableCellRendererComponent(table, value, selected, focused, row, column);
        return this;
 }

}